﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace TankeWar.Sprites
{
	class test { }

    internal abstract class TankeSprite : test
    {
        #region Attribute

        /// <summary>
        /// 主游戏对象
        /// </summary>
        protected Game MainGame;

        /// <summary>
        /// 小坦克移动方向
        /// </summary>
        protected TankeDirection Direction;

        /// <summary>
        /// 是否被子弹击中
        /// </summary>
        protected bool IsBeHit;

        /// <summary>
        /// 坦克贴图
        /// </summary>
        protected Texture2D TankeTexture2d;

        /// <summary>
        /// 坦克坐标及大小
        /// </summary>
        protected Rectangle TankeRect;

        /// <summary>
        /// 坦克的移动速度
        /// </summary>
        protected int MoveSpeed = 5;

        #endregion

        #region Method

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="game">主游戏</param>
        public TankeSprite(Game game)
        {
            Init(game);
        }

        /// <summary>
        /// 精灵初始化
        /// </summary>
        /// <param name="game"></param>
        protected abstract void Init(Game game);

        /// <summary>
        /// 坦克移动
        /// </summary>
        protected abstract void Move();

        /// <summary>
        /// 坦克开火
        /// </summary>
        protected virtual void Fire() { }

        /// <summary>
        /// 坦克爆炸
        /// </summary>
        protected virtual void Biast() { }

        /// <summary>
        /// 游戏更新
        /// </summary>
        /// <param name="gameTime">提供计时值的快照。</param>
        public virtual void Update(GameTime gameTime)
        {
            Move();
        }

        /// <summary>
        /// 游戏自我绘制
        /// </summary>
        /// <param name="spriteBatch"></param>
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(TankeTexture2d, TankeRect, new Rectangle(TankeRect.Width * (int)Direction,
                                   0, TankeRect.Width, TankeRect.Height), Color.White);
        }

        #endregion
    }
}
